﻿Imports System.Data.OleDb


Public Class discussionAdd
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If System.Web.HttpContext.Current.User.Identity.IsAuthenticated Then


        Else
            Response.Redirect("discussionForum.aspx")
        End If
    End Sub

    Protected Sub btnsubmit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnsubmit.Click


            Dim sql As String = "INSERT INTO Discussion (Title,DateCreated,UserIDFK) VALUES (@f1,@f2,@f3)"
            Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
            Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)

            cmd.Parameters.AddWithValue("@f1", txtmaintenancedescription.Text)
            cmd.Parameters.AddWithValue("@f2", Now.Date.ToString("dd/MM/yyyy"))
            cmd.Parameters.AddWithValue("@f3", Membership.GetUser(User.Identity.Name).ProviderUserKey)


            conn.Open()


            cmd.ExecuteNonQuery()

            conn.Close()

            cmd.Dispose()

            conn.Dispose()

            Response.Redirect("discussionAdd.aspx")



        



    End Sub
End Class